"""
Calculator类，简单的计算器

属性包括
- 无

方法
- main()，程序的入口函数
"""

class Calculator:
    def __init__(self):
        pass

    @staticmethod
    def main():
        '''
        计算器主体
        '''
        print("Welcome to the calculator!")
        while True:
            try:
                num1 = float(input("Please enter the first number: "))
                num2 = float(input("Please enter the second number: "))
                op = input("Please enter the operation you want to do: ")
                if op == "+":
                    print(num1 + num2)
                elif op == "-":
                    print(num1 - num2)
                elif op == "*":
                    print(num1 * num2)
                elif op == "/":
                    print(num1 / num2)
                else:
                    print("Invalid operation. Please try again.")
            except ValueError as e:
                print("Invalid input. Please try again.")
                print(e)
                continue
            except ZeroDivisionError as e:
                print("You can't divide by zero!")
                print(e)
                continue
            except Exception as e:
                print("Unknown error. Please try again.")
                print(e)
                continue
            finally:
                print("Thank you for using the calculator!")
                break
    def add(self, a, b):
        """
        add方法，返回两个数的和
        
        参数: 
        - a (float): 第一个加数
        - b (float): 第二个加数
        
        返回: 
        - float: 两数之和
        """
        return a + b                 
    def subtract(self, a, b):
        """
        subtract方法，返回两个数的差
        
        参数: 
        - a (float): 被减数
        - b (float): 减数
        
        返回: 
        - float: 两数之差
        """
        return a - b
if __name__ == "__main__":
    Calculator.main()
    